/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. A copy of the
 * WTFPL version 2 is provided in the source archive, at
 * example/WTFPL-2 .*/
#include <fake437.h>

int main(int argc, char* argv[]) {
  SDL_Surface* screen;
  SDL_Event ev;
  int x;
  int y;
  int done = 0;
  (void)argc;
  (void)argv;
  SDL_Init(SDL_INIT_VIDEO);

  screen = SDL_SetVideoMode(F437_DEFAULT_WIDTH_PX,
                            F437_DEFAULT_HEIGHT_PX, 0, 0);
  f437_put_rect(screen, 0, 0, F437_DEFAULT_WIDTH, F437_DEFAULT_HEIGHT, 178,
                f437_get_color(F437_COLOR_BBLUE),
                f437_get_color(F437_COLOR_CYAN));
  f437_put_string(screen, 0, 0,
                  "0123456789012345678901234567890123456789"
                  "0123456789012345678901234567890123456789",
                  f437_get_color(F437_COLOR_BRED),
                  f437_get_color(F437_COLOR_BBLACK));
  for (y = 0 ; y < 16 ; y++) {
    for (x = 0 ; x < 16 ; x++) {
      f437_put_char(screen,
                    x * F437_CHAR_WIDTH, (y + 1) * F437_CHAR_HEIGHT, y*16+x,
                    f437_get_color(F437_COLOR_BWHITE),
                    f437_get_color(F437_COLOR_BLACK));
    }
  }

  SDL_Flip(screen);
  while (!done) {
    while (SDL_PollEvent(&ev)) {
      if ((ev.type == SDL_KEYDOWN) &&
          (ev.key.keysym.sym == SDLK_ESCAPE)) done = 1;
    }
  }

  SDL_Quit();
  return 0;
}
